<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('客户评价列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
  <div class="row">
    <div class="col-sm-12 search-collapse">
      <form id="formId">
        <div class="select-list">
          <ul>
            <li>
              <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
              <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
            </li>
          </ul>
        </div>
      </form>
    </div>

    <div class="btn-group-sm" id="toolbar" role="group">
      <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()"
         shiro:hasPermission="project:projectCustomerEval:remove">
        <i class="fa fa-remove"></i> 删除
      </a>
    </div>
    <div class="col-sm-12 select-table table-striped">
      <table id="bootstrap-table" data-mobile-responsive="true"></table>
    </div>
  </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
  var editFlag = [[${@permission.hasPermi('project:projectCustomerEval:edit')}]];
  var removeFlag = [[${@permission.hasPermi('project:projectCustomerEval:remove')}]];
  const datas = [[${@dict.getType('rating_level')}]];
  var prefix = ctx + "project/projectCustomerEval";

  $(function () {
    var options = {
      url: prefix + "/list",
      createUrl: prefix + "/add",
      updateUrl: prefix + "/edit/{id}",
      removeUrl: prefix + "/remove",
      modalName: "客户评价",
      showExport: true,
      columns: [{
        checkbox: true
      },
        {
          field: 'evalId',
          title: '',
          visible: false
        },
        {
          field: 'projectName',
          title: '项目名称'
        },
        {
          field: 'projectRating',
          title: '项目评分',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(datas, value);
          }
        },
        {
          field: 'speedRating',
          title: '速度评分',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(datas, value);
          }
        },
        {
          field: 'resultRating',
          title: '效果评分',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(datas, value);
          }
        },
        {
          field: 'saleRating',
          title: '销售评分',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(datas, value);
          }
        },
        {
          field: 'techRating',
          title: '技术支持评分',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(datas, value);
          }
        },
        {
          field: 'diagRating',
          title: '诊断评分',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(datas, value);
          }
        },
        {
          field: 'updateTime',
          title: '评价时间'
        },
        {
          title: '操作',
          align: 'center',
          formatter: function (value, row, index) {
            let actions = [];
            if ($.common.isEmpty(row.projectRating)) {
              actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.evalId + '\')"><i class="fa fa-edit"></i>客户评价</a> ');
            } else {
              actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewEval(\'' + row.evalId + '\')"><i class="fa fa-remove"></i>查看评价</a>');
            }
            return actions.join('');
          }
        }]
    };
    $.table.init(options);
  });

  function viewEval(evalId) {
    const url = prefix + "/view/" + evalId;
    $.modal.openTab("查看评价", url);
  }
</script>
</body>
</html>